package com.heyqing.topic.ConvertToTitle_0168;

import java.util.Scanner;

/**
 * ClassName:ConvertToTitle
 * Package:com.heyqing.topic.ConvertToTitle_0168
 * Description:
 *
 * @Date:2024/9/18
 * @Author:Heyqing
 */
public class ConvertToTitle {
    public String convertToTitle(int columnNumber) {
        StringBuffer sb = new StringBuffer();
        while (columnNumber > 0) {
            int a0 = (columnNumber - 1) % 26 + 1;
            sb.append((char)(a0 - 1 + 'A'));
            columnNumber = (columnNumber - a0) / 26;
        }
        return sb.reverse().toString();
    }

    public static void start() {
        Scanner sc = new Scanner(System.in);
        System.out.println("columnNumber:");
        int columnNumber = sc.nextInt();
        ConvertToTitle convertToTitle = new ConvertToTitle();
        String res = convertToTitle.convertToTitle(columnNumber);
        System.out.println(res);
    }
}
